package cxy;

public class Rectangle {
	private float length = 1.0f;
	private float width = 1.0f;

	public Rectangle() {
	}

	public Rectangle(float length, float width) {
		this.setLength(length);
		this.setWidth(width);
	}

	public float getLength() {
		return length;
	}

	public void setLength(float length) {
		if (length <= 0) {
			this.length = this.length;
		} else {
			this.length = length;
		}
	}

	public float getWidth() {
		return width;
	}

	public void setWidth(float width) {
		if (width <= 0) {
			this.width = this.width;
		} else {
			this.width = width;
		}

	}

	public double getArea() {
		double area;
		return area = length * width;
	}

	public double getPerimeter() {
		double perimeter;
		return perimeter = length + width;
	}

	public String toString() {
		System.out.print("Rectangle[length=" + length + ",width=" + width + "]");
		return "";
	}

	public void testRectangle() {
		Rectangle rec = new Rectangle(-1f, 0f);
		System.out.println(rec.toString());
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Rectangle rec = new Rectangle();
		rec.testRectangle();
	}

}
